package de.hs_heilbronn;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;

import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;
import javax.faces.bean.SessionScoped;

@ManagedBean
@RequestScoped
public class TableStuds {

	private ArrayList<Stud> studList = new ArrayList<Stud>();

	// retrieves all student-objects from database and puts them into an ArrayList
	public TableStuds() {
		Database db = new Database();
		ResultSet rs = db.connectQuery("SELECT * FROM student;");

		try {
			while (rs.next()) {
				studList.add(new Stud(rs.getInt(1), rs.getString(2), rs.getString(3)));
			}
		} catch (SQLException e) {
			e.printStackTrace();
		}

	}

	public ArrayList<Stud> getStudList() {
		return studList;
	}

	public void setStudList(ArrayList<Stud> studentList) {
		this.studList = studentList;
	}
	
}
